package com.itheima;

import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;

/**
 * @ProjectName: ybxy6
 * @Titile: LinkedHashSetDemo
 * @Author: 86183
 * @Description: TODO
 */
public class LinkedHashSetDemo {
    public static void main(String[] args) {
        class Student {
            private String name;

            public Student(String name) {
                this.name = name;
            }

            @Override
            public String toString() {
                return "Student{name='" + name + '\'';}
        }
        //创建LinkedHashSet集合对象
        LinkedHashSet<Student> linkedHashSet = new LinkedHashSet<Student>();
        //创建Student对象
        linkedHashSet.add(new Student("马林"));
        linkedHashSet.add(new Student("坎特雷拉"));
        linkedHashSet.add(new Student("长离"));
        linkedHashSet.add(new Student("公孙离"));
        linkedHashSet.add(new Student("王昭君"));
        Iterator<Student> iterator  = linkedHashSet.iterator();
        while (iterator.hasNext()){
            String next = String.valueOf(iterator.next());
            System.out.println(next);
        }
    }
}
